package com.ms.service.module.zone.db;

import com.ms.game.bank.db.BankDAO;
import com.ms.service.error.ErrorCode;
import com.ms.service.module.datacenterlite.CentralAsyncCommand;
import com.ms.service.module.zone.message.SRechargePageResponse;
import com.xpec.c4.game.utility.GUID;
import com.xpec.c4.message.MessageTypes;
import com.xpec.c4.service.message.MessageAction;

public class LoadPlayerCashItemDCLAsync extends CentralAsyncCommand{
	
	public GUID sessionID;
	
	/**
	 * 帳號ID
	 */
	public GUID accountID;
	
	
	/**
	 * 包月到期時間
	 */
	public long monthlyFeeEndTime; 

	/**
	 * 包週到期時間
	 */
	public long weeklyFeeEndTime; 
	
	private int errorCode = ErrorCode.SUCCESS;
	
	private long cashPoint = 0;
	@Override
	public void asyncExecute() throws Exception {
		// TODO kevin loadAccountCash [v] 開啟儲值介面
		Object[] cashObj = BankDAO.loadAccountCashPoint(accountID);

		if (cashObj == null) {
			errorCode = ErrorCode.DB_OPERATION_FAIL;
		}else{
			cashPoint = (long) cashObj[0];
		}
	}

	@Override
	public void callBackExecute(Object... userData) throws Exception {
		// TODO Auto-generated method stub
		SRechargePageResponse response = new SRechargePageResponse();
		response.errorCode = errorCode;
		response.itemCount = 0;
		response.cashPoint = cashPoint;
		response.monthlyFeeEndTime = monthlyFeeEndTime;
		response.weeklyFeeEndTime = weeklyFeeEndTime;
		MessageAction.sendMessage(sessionID, MessageTypes.S_ZONE_OPEN_RECHAREGE_PAGE_RESPONSE, response);
	}

}
